<?php
namespace Home\Controller;
use Org\Yike\FangCms;
class IndexController extends CommonController {
    public function _initialize(){
        parent::_initialize();
    }

    public function index(){
        //echo _md5('123456');exit;
        //广告列表
        $this->img_list = getAds(3,8);
        //推
        $this->pos_list = getPosition(array(1,2,3,4,5,6,7,12));

        //团购
        $group = M('group')->where(array('status'=>1))->field('id,title,number,original_price,present_price,end_time,img,list_img')->order('id desc')->limit(8)->select();
        $this->group = $group;

        //热门小区
        $top_estate = M('estate')->where(array('status'=>1))->order('hits desc')->limit(8)->select();
        $this->top_estate = $top_estate;

        //新房推荐
        $this->rec_house = M('house')->where(array('status'=>1,'is_rec'=>1))->order('ordid desc')->limit(3)->select();
        //二手房推荐
       // $this->rec_used = M('used')->where(array('status'=>1,'is_rec'=>1))->order('ordid desc')->limit(3)->select();
        $this->rec_used = M('used')->where(array('status'=>1,'is_rec'=>1))->limit(3)->select();
        //经济人
        $index_user = M('user_info')->where(array('status'=>1,'cate_id'=>2,'is_index'=>1))->order('id desc')->limit(3)->select();
        $this->index_user_list = array();
        foreach($index_user as $v){
            $index_user_list[$v['id']] = $v;
            $index_user_list[$v['id']]['used_housing'] = M('used')->where(array('user_id'=>$v['user_id']))->count();
            $index_user_list[$v['id']]['rental_housing'] = M('used')->where(array('user_id'=>$v['user_id']))->count();
        }

        $this->index_user =$index_user_list;
        $this->activity = M('activity')->where(array('status'=>1))->field('id,title,cate_id')->limit(8)->order('id desc')->select();
        $this->activity_cate = cateFor('','activity_cate');
        $this->lpxw = getArticleList(4);   //获取楼盘新闻
        $this->djbd = getArticleList(2);   //获取独家报道
        $this->answer_list = getAnswerList(6);    //回答列表
        //友情
        $this->link = M('link')->where(array('status'=>1))->order('ordid desc')->limit(40)->select();
        $this->display();
    }

}